package org.lock4j.config;

import com.baomidou.lock.DefaultLockFailureStrategy;
import com.baomidou.lock.DefaultLockKeyBuilder;
import com.baomidou.lock.LockFailureStrategy;
import com.baomidou.lock.LockKeyBuilder;
import com.baomidou.lock.spring.boot.autoconfigure.LockAutoConfiguration;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yexi
 * @see LockAutoConfiguration 默认配置
 * @see com.baomidou.lock.spring.boot.autoconfigure.RedissonLockAutoConfiguration Redisson锁自动配置器
 */
@Configuration
public class Lock4jConfiguration {

    /**
     * 抢占锁失败执行策略
     *
     * @see LockAutoConfiguration#lockFailureStrategy() 默认策略
     */
    @Bean
    public LockFailureStrategy lockFailureStrategy() {
        return new DefaultLockFailureStrategy();
    }

    /**
     * 自定义分布式锁key生成规则
     *
     * @see LockAutoConfiguration#lockKeyBuilder() 默认生成器
     */
    @Bean
    public LockKeyBuilder defaultLockKeyBuilder() {
        return new DefaultLockKeyBuilder();
    }

}
